<extend name="Public/base"/>

<!-- 子导航 -->
<block name="sidebar">
  <include file="sidemenu" />
</block>


<block name="body">
<!-- 标题 -->
<div class="main-title">
    <h2>
    我的文档({$_total})
    </h2>
</div>

<div class="panel panel-default">
    <div class="panel-heading">		
		<div class="fl">
            <button class="btn btn-default ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>1))}">启 用</button>
			<button class="btn btn-default ajax-post" target-form="ids" url="{:U("Article/setStatus",array("status"=>0))}">禁 用</button>
			<button class="btn btn-default ajax-post confirm" target-form="ids" url="{:U("Article/setStatus",array("status"=>-1))}">删 除</button>
		</div>		
		<!-- 高级搜索  TODO:-->
	</div><!-- /.panel-heading -->
	<!-- 数据表格 -->
	<div class="panel-body">
		<div class="table-responsive">		
			<table class="table table-striped table-bordered table-hover" id="dataTables-mydocment"><!-- 必须设定表格的id == -->
				<thead>
					<tr>
                    <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                    <th class="">编号</th>
                    <th class="">标题</th>
                    <th class="">子文档</th>
                    <th class="">类型</th>
                    <th class="">分类</th>
                    <th class="">优先级</th>
                    <th class="">最后更新</th>
                    <th class="">浏览</th>
                    <th class="">状态</th>
                    <th class="">操作</th>
                </tr>
                </thead>
                <tbody>
                    <volist name="list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{$vo.id}" /></td>
                        <td>{$vo.id} </td>
                        <td><a href="{:U('Article/index?cate_id='.$vo['category_id'].'&pid='.$vo['id'])}">{$vo.title}</a></td>
                        <td><span>{:get_subdocument_count($vo['id'])}</span></td>
                        <td><span>{:get_document_type($vo['type'])}</span></td>
                        <td><span>{:get_cate($vo['category_id'])}</span></td>
                        <td>{$vo.level}</td>
                        <td><span>{$vo.update_time|time_format}</span></td>
                        <td>{$vo.view}</td>
                        <td>{$vo.status_text}</td>
                        <td><a href="{:U('Article/edit?cate_id='.$vo['category_id'].'&id='.$vo['id'])}">编辑</a>
                            <a href="{:U('Article/setStatus?ids='.$vo['id'].'&status='.abs(1-$vo['status']))}" class="ajax-get">{$vo.status|show_status_op}</a>
                            <a href="{:U('Article/setStatus?status=-1&ids='.$vo['id'])}" class="confirm ajax-get">删除</a>
                            </td>
                    </tr>
                    </volist>
                </tbody>
			</table>
		</div><!-- /.table-responsive --> 
	</div><!-- /.panel-body -->
</div><!-- /.panel --> 						
</block>


<block name="script">
<script type="text/javascript">
//启用表格功能  id 是  
$(document).ready(function() {
	$('#dataTables-mydocment').dataTable();
});
</script>
 
<script type="text/javascript">
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query += 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 状态搜索子菜单 */
	$(".search-form").find(".drop-down").hover(function(){
		$("#sub-sch-menu").removeClass("hidden");
	},function(){
		$("#sub-sch-menu").addClass("hidden");
	});
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
			$("#sub-sch-menu").addClass("hidden");
		})
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });

    $('#datetimepicker').datetimepicker({
       format: 'yyyy-mm-dd',
        language:"zh-CN",
        minView:2,
        autoclose:true,
        pickerPosition:'bottom-left'
    })
    
})
</script>
</block>
